<template>
  <div class="container">
    <mt-header fixed title="行程详情">
      <router-link :to="{name:'admin'}" slot="left">
        <mt-button icon="back">返回</mt-button>
      </router-link>
    </mt-header>
    <div class="detail_post">
      <img :src="project.displayImgUrl" />
    </div>
    <div class="detail_title border-bottom">
      <p>{{project.projectName}}</p>
    </div>
    <div class="detail_summary border-bottom">
      <div class="detail_summary_item border-bottom"><i class="detail-time"></i>{{project.projectStartTime}} ~ {{project.projectEndTime}}</div>
      <div class="detail_summary_item border-bottom"><i class="detail-number"></i>已报名{{project.bookedNumber}}人</div>
      <div class="detail_summary_desciption"><i class="detail-zone"></i>线路景点：  <pre v-for="item in project.scenicZones">{{item.scenicZoneName}}</pre></div>
    </div>
    <div class="detail_description">
      <p>{{project.projectDesc}}</p>
    </div>
    <div class="detail_images">
      <ul v-for="images in project.introImages">
        <li><img :src="images.introImageUrl"/></li>
      </ul>
    </div>
    <div class="weui-flex">
      <div class="weui-flex__item border-bottom">已报名</div>
      <div class="weui-flex__item border-bottom" style="text-align: right; padding-right: 18px; color:#F15F5C;">
          <router-link :to="{name: 'TouristDetailBookedUsers', params:{projectId:project.id}}">查看更多 ></router-link>
      </div>
    </div>

    <div class="weui-flex  bottom-padding" >
      <div class="weui-flex__item user-detail__img" v-for ="item in bookedUserList" v-if="bookedUserList.length >0" >
        <img  src="../../assets/avatar.png" alt="">
        <div class="user-detail-name">{{item.contactName}}</div>
      </div>
    </div>

    <mt-actionsheet
      :actions="actions"
      v-model="sheetVisible">
    </mt-actionsheet>

    <div class="tourist_delete">
      <mt-button type="default" size="large" @click="this.deleteProject">删除</mt-button>
    </div>

    <div class="tourist_edit">
     <router-link class="weui-btn" :key="this.touristId" :to="{name: 'touristEdit', params:{touristId:this.touristId}}" >编辑</router-link>
    </div>
  </div>
</template>
<script>
  import fetch from '../../utils/fetch'
  import MtCell from "../../../node_modules/mint-ui/packages/cell/src/cell";
  import MtButton from "../../../node_modules/mint-ui/packages/button/src/button";

  export default{
    data (){
      return {
        selected: '1',
         project: {
            'id':'',
            'projectName': '',
            'displayImgUrl': require('../../assets/header.jpg'),
            'projectStartTime':'',
            'projectEndTime':'',
            'projectDesc':'',
            'limitNumber':'',
            'introImages':[
              {
                'introImageUrl':require('../../assets/detail-img-1.jpg'),
                'order':'',
                'active':false,
                'error':false
              }
            ],
            'scenicZones': []
         },
        currentProjectId: '',
        bookedUser:{
          'id':'',
          'projectId':'',
          'projectName':'',
          'contactName':'',
          'contactPhone':''
        },
        touristId: 0,
        currentClass: 'cb',
        pageReq:{
          count:'',
          page:'',
          projectId: ''
        },
        bookedUserList:[],
        sheetVisible: false,
        actions: [{
          name: '确认删除',
          method: this.confirmDelete
        }]
      }
    },
    components:{
      MtButton
    },
    created(){
      this.handleGetProject();
    },
    computed:{
    },
    methods:{
      handleGetProject(){
        this.touristId = this.$route.params.touristId;
        fetch('/api/project/info/' +this.touristId ).then(response =>{
          if(response.data.success) {
            this.project = response.data.response
            this.handleGetProjectBookedUser(this.project.id);
          }
        })
      },
      handleGetProjectBookedUser(projectId){
        this.pageReq.count = 5;
        this.pageReq.page = 0;
        this.pageReq.projectId = projectId;
        let formData = JSON.stringify(this.pageReq)

        fetch.post('/api/project/booked/list' ,formData).then(response =>{
          if(response.data.success) {
            this.bookedUserList = response.data.response
          }
        })
      },
      deleteProject(){
        this.sheetVisible = true;
      },
      confirmDelete(){
        fetch.delete('/api/project/delete/'+this.project.id).then(response =>{
          if(response.data.success){
            this.$router.replace({path: '/home/admin'})
          }
        })
      }
    },

    deactivated () {
      this.$destroy()
    }
  }
</script>
<style scoped lang="scss">
  @import '../../../static/css/weui.css';
  @import '../../base/css/_base';
  @import '../../../node_modules/mint-ui/lib/style.css';
  .mint-navbar{
    margin: 0 0 10px;
  }
  .mint-header{
    font-size: 16px;
    height: 45px;
    line-height: 45px;
    background-color: #f2f2f2 !important;
    box-sizing: border-box;
    color: #101010;
  }
  .container{
    background-color: #fff;
    height: 100%;
  }
  .detail_post{
       height: 216px;
       width: 100%;
       margin-top: 45px;
  }
  .detail_post img{
        height: 216px;
        width: 100%;
  }
  .detail_title{
    width:100%;
    padding-top: 11px;
    padding-bottom: 11px;
       box-sizing: border-box;
  }
     .detail_title p{
       font-size:18px;
       color: #101010;
       padding: 5px 0;
     }
  .border-bottom{
      background-image: -webkit-linear-gradient(bottom, #e5e5e5, #e5e5e5 50%, transparent 50%);
      background-size: 100% 1px;
      background-repeat: no-repeat;
       background-position: bottom;
  }
  .detail_summary{
    padding-top: 0;
    padding-bottom: 0;
    word-break: break-word;
  }
  .detail_summary_item,.detail_summary_desciption{
    padding: 9px 0;
    line-height: 20px;
  }
  .detail_summary_desciption{
    color:#030303;
    letter-spacing:-1px;
       pre{
        padding-left:22px;
       }
  }
  .detail_description{
      height: auto;
      padding-top: 10px;
      padding-bottom: 10px;
      word-break: break-word;
      color: #101010;
      line-height: 20px;
  }
     .weui-flex{
         .weui-flex__item{
             padding: 10px 0;
             color: #101010;
         }
     }
    .weui-flex.bottom-padding{
        padding-bottom: 100px !important;
     }
  .detail_images{
    height: auto;
  }
  .detail_images img{
    width: 100%;
    height: auto;
    padding-top: 10px;
  }


  .tourist_edit{
    position: fixed;
    bottom: 0;
    height: 50px;
    width: 100%;
      .weui-btn{
        background-color: #F15F5C;
        border-radius: 0;
        height: 50px;
        line-height: 50px;
        font-size: 16px;
      }
  }
  .tourist_delete{
    position: fixed;
    bottom: 50px;
    height: 50px;
    width: 100%;
    .weui-btn{
      background-color: #cccccc;
      border-radius: 0;
      height: 50px;
      line-height: 50px;
      font-size: 16px;
    }
  }
  .detail_title,.detail_summary,.weui-flex,.detail_description{
      padding-right:18px;
      padding-left:18px;

  }
   .detail_title,.detail_summary,.detail_description{
      line-height: 18px;
  }
      .detail-time,.detail-number,.detail-zone{
         width: 22px;
         height: 22px;
         display: inline-block;
         vertical-align: bottom;
         background-position: center;
         background-color: #fff;
         background-repeat: no-repeat;
         background-size: 90%;
      }
       .detail-time{
          background-image: url(../../../static/images/detail-time.png);
       }
       .detail-number{
          background-image: url(../../../static/images/detail-number.png);
       }
       .detail-zone{
          background-image: url(../../../static/images/detail-zone.png);
       }
    .signup_sec{

    }
    .detail_summary_item .fa,.detail_summary_desciption .fa{
      padding-right: 10px;
      color: #858585;
      font-size: 20px;
    }
  .user-detail__img{
    margin: 2px;
    img{
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
    .user-detail-name{
      font-size:12px;
      color:#101010;
    }
  }
  a:link{text-decoration:none;}
  a:visited{text-decoration:none;}
  a:hover{text-decoration:none;}
  a:active{text-decoration:none;}
  .eclipse{
    display: -webkit-box;
    text-overflow:ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    line-height: 1.2;
  }
</style>
